#ifndef PDFFILE_H
#define PDFFILE_H

#include <QObject>
#include <QImage>
#include <QFileInfo>
#include <poppler/qt4/poppler-qt4.h>
#include <QDebug>
#include "passworddialog.h"
//#include "imgmgr.h"
#include "config.h"


class PDFFile : public QObject
{
    Q_OBJECT

private:
    Poppler::Document* m_doc;
    int m_pageCount;
    QByteArray m_password;
    int m_resolution;
    inline int resolution () { return m_resolution; }

public:
    explicit PDFFile (QObject *parent = 0);
    ~PDFFile () ;

    bool containsText ();
    void setResolution (const int r) { m_resolution = r; }
    void clear ();
    bool load (const QString& fileName);
    bool isLocked () { return !m_password.isEmpty (); }
    QString password () { return QString (m_password); }
    QImage pageImage (int pageNum);
    QString textInRects (const int pageNum,
                         const QVector<QRectF>& selection,
                         const bool usePdfToText,
                         const QString& documentPath);
    QString textInPages (const int first,
                         const int last,
                         const bool usePdfToText,
                         const QString& documentPath);
    int pageCount () { return m_doc->numPages (); }

signals:

public slots:

};

#endif // PDFFILE_H
